<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <!-- ========================= v-on ========================= -->
    <div id="app-on">
        <p>{{message}}</p>
        <button v-on:click = "reverseMessage">点击反转字符串</button>
    </div>

    <script>
        new Vue({
            el: '#app-on',
            data: {
                message: 'Hello Vue.js!'
            },
            methods: {
                reverseMessage: function () {
                    this.message = this.message.split('').reverse().join('')
                }
            }
        })
    </script>

    <!-- v-model:输入与数据双向绑定 -->
    <div id="app-model">
        <p>{{message}}</p>
        <input type="text" v-model = "message">
    </div>

    <script>
        new Vue({
            el: '#app-model',
            data: {
                message: 'Hello Vue.js!'
            }
        })
    </script>

</body>

</html>